package com.guoguo.controller;

import com.guoguo.entity.Category;
import com.guoguo.entity.Images;
import com.guoguo.service.ICategoryService;
import com.guoguo.service.IImagesService;
import com.guoguo.utils.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import java.io.*;
import java.util.Date;

/**
 * Created by Administrator on 2017/8/24.
 */
@Controller
@RequestMapping("/view")
public class ImageController {
    @Autowired
    private IImagesService imagesService;

    @RequestMapping(value = "/images", method = RequestMethod.GET)
    public String image() {

        return "/images";
    }

    //保存图片
    @RequestMapping(value = "/saveImages", method = RequestMethod.POST)
    public String saveImages(String imgName, String imgDescription, Integer sort, Integer commentNum, Integer shareNum, Integer favoriteNum) {
        Images images = new Images();
        images.setImgName(imgName);
        images.setImgDescription(imgDescription);
        images.setSort(sort);
        images.setCommentNum(commentNum);
        images.setShareNum(shareNum);
        images.setFavoriteNum(favoriteNum);
        int i = imagesService.insertSelective(images);
        if(i>0){
            return "1";
        }else{
            return "0";
        }
    }



}
